package com.cctc.rds.scheduler.client.worker;

import com.cctc.rds.scheduler.core.task.impl.AbstractTask;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class PrintTask extends AbstractTask<String> {
    private String taskName;

    public PrintTask(String taskName) {
        this.taskName = taskName;
    }

    @Override
    public String getTaskName() {
        return taskName;
    }

    @Override
    public String getTaskParam() {
        return taskName;
    }

    @Override
    public boolean run(long curPeriod, String taskParam) {
        System.out.println("[" + curPeriod + "] ==> " +
                taskParam + "-" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        return curPeriod >= 5;
    }
}
